﻿using System;
using Framework.Core.Cache;
using Xunit;

namespace Framework.Tests.Core.Cache
{
    public class CacheEntryTest
    {
        [Fact]
        public void Should_not_be_valid_if_nohit()
        {
            var cacheEntry = new CacheEntry(new TimeSpan(1), "1");

            Assert.Equal(1, cacheEntry.Hit);

            Assert.True(cacheEntry.IsValid(new TimeSpan(1, 0, 0, 0)));
            Assert.False(cacheEntry.IsValid(new TimeSpan(-1)));
            cacheEntry.ResetStatistics();

            Assert.Equal(0, cacheEntry.Hit);

            Assert.False(cacheEntry.IsValid(new TimeSpan(1)));
            Assert.False(cacheEntry.IsValid(new TimeSpan(1)));
        }
    }
}
